﻿using NHibernate.Criterion;

namespace Model.Repositories.User
{
    public class UserRepository : Repository<Entities.User>
    {
        public Entities.User GetByEmailAndPassword(string email, string password)
        {
            var obj = Session.CreateCriteria<Entities.User>().Add(Restrictions.Eq("Email", email)).Add(Restrictions.Eq("Password", password)).List<Entities.User>();
            if (obj != null && obj.Count == 1)
                return obj[0];
            return null;
        }

        public Entities.User GetByEmail(string email)
        {
            var obj = Session.CreateCriteria<Entities.User>().Add(Restrictions.Eq("Email", email)).List<Entities.User>();
            if (obj != null && obj.Count == 1)
                return obj[0];
            return null;
        }
    }
}